package com.qg.auth.util;

import org.springframework.context.ApplicationContext;

/**
 * @Author QG
 * @Date 2023/5/29 14:25
 * @description
 **/
public class WebBeanFactory {

    private static ApplicationContext applicationContext;

    public static void setApplicationContext(ApplicationContext applicationContext) {
        WebBeanFactory.applicationContext = applicationContext;
    }
    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }


    public static Object getBean(String beanName) {
        Object bean = applicationContext.getBean(beanName);
        return bean;
    }

    public static <T> T getBean(Class<T> clazz) {
        T bean = applicationContext.getBean(clazz);
        return bean;
    }


    public static <T> T getBean(String beanName,Class<T> requireType) {
        T bean = applicationContext.getBean(beanName, requireType);
        return bean;
    }

}
